package com.example.liteflow.itr;

import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeIteratorComponent;
import com.yomahub.liteflow.slot.Slot;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import lombok.extern.slf4j.Slf4j;

/**
 * 迭代循环组件
 *
 * @author chen.an
 * @date 2024-08-14 18:04
 */
@Slf4j
@LiteflowComponent(id = "IteratorNode", name = "迭代循环组件")
public class IteratorNode extends NodeIteratorComponent {
    @Override
    public Iterator<?> processIterator() throws Exception {
        Slot slot = this.getSlot();
        String str = slot.getRequestData();
        log.info("IteratorNode 节点组件【{}】-IteratorNode,获取数据：{}", Thread.currentThread().threadId(), str);
        List<String> list = new ArrayList<>();
        list.add("data1");
        list.add(str);
        return list.iterator();
    }
}
